home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 751-760 / 760 / p-compress / objectfm / decrunchfm.s < prev   
Text File  |  1995-03-18  |  3KB  |  145 lines

  1.    
  2.             OPT ALINK
  3.  
  4.             XREF  _decompressFM
  5.             XDEF  _DOSBase
  6.  
  7.        movea.l a0,a4       preserve command line
  8.        clr.b   -1(a4,d0.w)
  9.        lea     dosname,a1
  10.        move.l  4,A6
  11.        jsr     -408(a6)    OldOpenLibrary
  12.        move.l  d0,_DOSBase
  13.  
  14.        move.l  _DOSBase,A6
  15.        jsr     -60(a6)     Output
  16.        move.l  d0,stdout
  17.  
  18.        move.l  a4,d1       input filename
  19.        move.l  #1005,d2    MODE_OLDFILE
  20.        move.l  _DOSBase,A6
  21.        jsr     -30(a6)     Open
  22.        move.l  d0,fi       input file handle 
  23.  
  24.        move.l  #fname,d1   'ram:q'
  25.        move.l  #1006,d2    MODE_NEWFILE
  26.        move.l  _DOSBase,A6
  27.        jsr     -30(a6)     Open
  28.        move.l  d0,fo       output file-handle
  29.  
  30.        move.l  #6,d3       read 'lh,decompressed size'
  31.        move.l  #buffer,d2
  32.        move.l  fi,d1
  33.        move.l  _DOSBase,A6
  34.        jsr     -42(a6)     Read
  35.        moveq.l #-1,d3
  36.        moveq.l #2,d2
  37.        move.l  fi,d1
  38.        move.l  _DOSBase,a6
  39.        jsr     -66(a6)     Seek to position in file after 'LH' 
  40.  
  41.  
  42.        lea     buffer,a0
  43.        cmpi.w  #$4C48,(a0) check that file is compressed
  44.        beq     compressed
  45.        move.l  #$14,d3
  46.        move.l  #notcomp,d2
  47.        move.l  stdout,d1
  48.        move.l  _DOSBase,a6
  49.        jsr     -48(a6) 
  50.        bra     close
  51.  
  52. compressed
  53.        move.l  length,d0
  54.        move.l  #$10001,d1      MEMF_PUBLIC|MEMF_CLEAR
  55.        move.l  4,A6
  56.        jsr     -198(a6)       AllocMem
  57.        move.l  d0,obuf
  58.  
  59. ;       move.l  length,-(a7)
  60.        move.l  obuf,-(a7)
  61.        move.l  fi,-(a7)
  62.        jsr     _decompressFM
  63.        addq.l  #8,a7    add.l   #$C,a7
  64.  
  65.        cmpi    #1,d0
  66.        bne     decompOK
  67.        move.l  #$14,d3
  68.        move.l  #baddecomp,d2
  69.        move.l  stdout,d1
  70.        move.l  _DOSBase,a6
  71.        jsr     -48(a6)      Write
  72.        jmp     close
  73.  
  74. decompOK
  75.        cmpi    #2,d0
  76.        bne     memOK
  77.        move.l  #$21,d3
  78.        move.l  #nomem,d2
  79.        move.l  stdout,d1
  80.        move.l  _DOSBase,a6
  81.        jsr     -48(a6)      Write
  82.        jmp     close
  83.  
  84. memOK
  85.        move.l  length,d3
  86.        move.l  obuf,d2      Decoded output
  87.        move.l  fo,d1
  88.        move.l  _DOSBase,a6
  89.        jsr     -48(a6)      Write
  90.  
  91.        ;(insert code to use output in obuf)
  92.  
  93. close
  94.        tst.l   fi
  95.        beq.b   closefo
  96.        move.l  fi,d1
  97.        move.l  _DOSBase,A6
  98.        jsr     -36(a6)      Close
  99. closefo
  100.        tst.l   fo
  101.        beq.b   freeobuf
  102.        move.l  fo,d1
  103.        move.l  _DOSBase,A6
  104.        jsr     -36(a6)      Close
  105. freeobuf
  106.        tst.l   obuf
  107.        beq.b   quit
  108.        move.l  obuf,a1
  109.        move.l  length,d0
  110.        move.l  4,A6
  111.        jsr     -210(a6)     FreeMem 
  112. quit
  113.        rts
  114.        
  115. _DOSBase     dc.l  0
  116. fi          dc.l  0
  117. fo          dc.l  0
  118. stdout      dc.l  0
  119. obuf        dc.l  0
  120. buffer      dc.w  0
  121. length      dc.l  0
  122. dosname     dc.b  'dos.library',0
  123. fname       dc.b  'ram:q',0
  124. notcomp     dc.b  'file not compressed',10,0
  125. nomem       dc.b  'insufficient memory',10,0
  126. baddecomp   dc.b  'decompression failed',10,0
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.